PowerTCP Mail for .NET
MVC Design in Applications



Extending the Model-View-Controller Design Philosophy to Applications

One feature of the new version 4 components is the ease with which applications can be developed using a Model-View-Controller (MVC) design. MVC is a design philosophy that isolates application business logic from the user interface. The following white paper offers a detailed discussion of this design and its application to the PowerTCP and PowerSNMP components:

http://www.dart.com/articles_mvc.aspx

MVC design has been incorporated into some of the more sophisticated PowerTCP and PowerSNMP sample applications, providing two key benefits:

Separation of protocol logic from the user interface

Encapsulating protocol logic in a class separates it from any user interface, providing clean code that can be reused in other projects, with other interfaces.

The Smtp, Pop and Imap Client samples provide a nice demonstration of this separation. These samples implement a model class where all code pertaining to communication logic - logging in, sending and retrieving email, manipulating messages on the server - resides. The protocol functionality can easily be extended or modified without affecting the UI. These model classes can easily be reused in other applications, with other interfaces. In addition, encapsulating the data and logic pertaining only to protocol functions provides a cleaner project that is easier to digest and maintain.

Simplified storage of runtime state information

Saving runtime state information and persisting this information when the application is terminated is a key feature of many applications. Model classes can facilitate this.

Again, the Smtp, Pop and Imap Client samples are typical examples.

First, each sample's model class provides properties for storing runtime data, including session data and security settings. This class provides a "ground truth" for the state of the application, instead of the interface itself holding this information. The interface provides a means for updating the model, but is itself "dumb." Also, the encapsulated data can be easily passed to objects such as Settings and Connection forms, which are implemented as interfaces for updating the information contained within the model.

Second, as a serializable class, the model provides a means for easily persisting settings when the application is terminated. In the past, PowerTCP and PowerSNMP samples dedicated large chunks of code for saving and loading application settings, usually in the registry. PowerTCP 4 components have taken a different approach, focusing instead on providing help for serialization. This includes helper functions for Serializing and Deserializing objects to and from streams, as well as providing state information in serializable objects that can be easily stored. For example, the SmtpModel class stores an SmtpSession object which includes RemoteEndPoint, Username, Password, Security information and much more.


The sample applications are available as an option during the product installation, and can also be downloaded by clicking on the "Download Samples" link in the Start Menu.


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic